package comframe.jdbc.sql.support;

import java.sql.SQLException;
import java.util.List;

import comframe.jdbc.sql.condition.Condition;

/**
 * 查询模板接口
 * 
 * @author ray
 * 
 */
public interface Templete {
	/**
	 * 保存 对象
	 * 
	 * @throws SQLException
	 */
	public abstract boolean save(final Object object) throws Exception;

	/**
	 * 删除 对象
	 * 
	 * @throws SQLException
	 */
	public abstract boolean delete(final Object object) throws Exception;

	/**
	 * 更新 对象
	 * 
	 * @throws SQLException
	 */
	public abstract boolean update(final Object object, Condition condition)
			throws Exception;

	/**
	 * 更新 对象
	 * 
	 * @throws SQLException
	 */
	public abstract boolean updateIsExist(final Object object,
			Condition condition) throws Exception;

	/**
	 * 更新 对象
	 * 
	 * @throws SQLException
	 */
	public abstract boolean update(final Object object) throws Exception;

	/**
	 * 更新 对象
	 * 
	 * @throws SQLException
	 */
	public abstract boolean updateIsExist(final Object object)
			throws Exception;

	/**
	 * 删除
	 * 
	 * @throws SQLException
	 */
	public abstract boolean delete(Condition condition, Class<?> clazz)
			throws Exception;

	/**
	 * 查询 对象
	 * 
	 * @throws SQLException
	 */
	public abstract List<Object> find(Class<?> clazz) throws Exception;
	
	/**
	 * 查询 对象
	 * 
	 * @throws SQLException
	 */
	public abstract Object findById(Class<?> clazz,Object value) throws Exception;

	/**
	 * 查询 对象
	 * 
	 * @throws SQLException
	 */
	public abstract List<Object> find(Condition condition, Class<?> clazz)
			throws Exception;

	/**
	 * 查询总数
	 * 
	 * @param clazz
	 * @return
	 * @throws SQLException
	 */
	public abstract Integer count(Class<?> clazz) throws Exception;

	/**
	 * 
	 * @param conditionSql
	 *            条件
	 * @param clazz
	 * @return
	 * @throws SQLException
	 */
	public Integer count(Condition condition, Class<?> clazz)
			throws Exception;

	/**
	 * 分页查询
	 * 
	 * @param page
	 * @param pageSize
	 * @param clazz
	 * @return
	 * @throws SQLException
	 */
	public List<Object> PageQuery(int page, int pageSize, Class<?> clazz)
			throws Exception;

	/**
	 * 带条件的分页查询
	 * 
	 * @param page
	 * @param pageSize
	 * @param conditionSql
	 * @param clazz
	 * @return
	 */
	public List<Object> PageQuery(int page, int pageSize, Condition condition,
			Class<?> clazz) throws Exception;

	/**
	 * 删除所有
	 * 
	 * @param clazz
	 * @return
	 * @throws SQLException
	 */
	public boolean deleteAll(Class<?> clazz) throws Exception;

	/**
	 * sql语句查询
	 * 
	 * @param sql
	 * @param clazz
	 * @return
	 * @throws SQLException
	 */
	public List<Object> querySql(String sql, Class<?> clazz)
			throws Exception;
}
